import {getcate,getbanner} from '../../utils/api'

const state={
    cate:[],
    banner:[]
}

const mutations={
    changecate(state,arr){
        state.cate=arr
    },
    changebanner(state,arr){
        state.banner=arr
    }
}

const actions={
    reqchangecate(context){
        getcate().then(res=>{
            let list=res.data.list?res.data.list.splice(0,5):res.data.list
            context.commit('changecate',list)
            // console.log(list);
        })
    },
    reqchangebanner(context){
        getbanner().then(res=>{
            context.commit('changebanner',res.data.list)
            console.log(res.data.list);
        })
    }
}
const getters={
    cate(state){
        return state.cate
    },
    banner(state){
        return state.banner
    }
}


export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}